using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FiltronASP.Logger;

namespace FiltronASP.Models.DAO.WIX
{
    public class WixFilterEngineFootnoteDAO : Abstracts.AbstractGenericDAO<WixFilterEngineFootnote, System.Nullable<int>>,
        Interfaces.WIX.IWixFilterEngineFootnoteDAO
    {
        /// <summary>
        /// Metoda zwracajaca nazwe parametru bedacego kluczem glownym tabeli.
        /// </summary>
        /// <returns>nazwa klucza glownego</returns>
        protected override string GetKeyProperty()
        {
            return "filter_engine_footnote_id";
        }

        public IQueryable<WixFilterEngineFootnote> FindByFilterEngineId(int filterEngineId)
        {
            if (filterEngineId.Equals(0))
            {
                return null;
            }
            try
            {
                IQueryable<WixFilterEngineFootnote> filterEngines = this._cmsEntitiesDataContext.WixFilterEngineFootnotes.Where(
                        fieenfo => fieenfo.filter_engine_id.Equals(filterEngineId)
                    );
                if (!(filterEngines.Any()))
                    return null;
                return filterEngines;
            }
            catch (Exception ex)
            {
                MyLogger.Log(ex);
            }

            return null;
        }

    }
}
